package com.yangxc.controller;

import com.alibaba.fastjson.JSON;
import com.yangxc.core.common.api.Result;
import com.yangxc.core.log.annotation.SysLog;
import com.yangxc.model.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Date;
import java.util.Map;

/**
 * @author yangxc
 * @version 1.0.0
 * @ClassName TestController.java
 * @Description TODO
 * @createTime 2021年07月02日 11:19:00
 */
@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {

    @SysLog("getTest")
    @GetMapping("/getTest/{id}")
    public Result<User> getTest(@PathVariable String id){
        log.info("getTest:{}",id);
        User user = User.builder().date(new Date()).localDate(LocalDate.now())
                .localDateTime(LocalDateTime.now()).localTime(LocalTime.now()).build();
        return Result.data(user);
    }

    @SysLog("postTest")
    @PostMapping("/postTest")
    public String postTest(@RequestBody Map map){
        log.info("postTest:{}", JSON.toJSONString(map));
        return JSON.toJSONString(map);
    }
}
